package com.booter.webflux.config;

public class RedisConfig {

//    @Bean(name = "reactiveRedisTemplate")
//    public ReactiveRedisTemplate<String, Object> reactiveRedisTemplate(ReactiveRedisConnectionFactory factory) throws JsonProcessingException {
//        RedisSerializationContext.RedisSerializationContextBuilder<String, Object> builder = RedisSerializationContext.<String, Object>newSerializationContext();
//        ObjectMapper mapper = new ObjectMapper();
//        JavaTimeModule timeModule = new JavaTimeModule();
//        timeModule.addSerializer(Date.class, new DateSerializer(Boolean.FALSE, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")));
//        timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        timeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//        timeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
//        timeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//        timeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//        timeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
//        mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
//        mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
//        mapper.registerModule(timeModule);
//        mapper.registerModules(ObjectMapper.findModules()).registerModule(new ParameterNamesModule());
//        Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class);
//        serializer.setObjectMapper(mapper);
//        builder.key(new StringRedisSerializer());
//        builder.value(serializer);
//        builder.hashKey(new StringRedisSerializer());
//        builder.hashValue(serializer);
//        return new ReactiveRedisTemplate<String, Object>(factory, builder.build());
//    }
}
